package uc.allapp;

import java.util.ArrayList;

import org.json.JSONArray;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import cn.onekit.JSON;
import cn.onekit.MESSAGE;
import cn.onekit.android.ACTIVITY;
import co.chuangdian.oflauncher.OFActivity;
import co.chuangdian.oflauncher.R;

public class AllAppActivity extends OFActivity {
	JSONArray appIDs;
	public final static String message = "AllAppActivity";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.all_app);
		final AllAppView allAppView = (AllAppView) this.findViewById(R.id.allAppView);
		final ImageButton doneButton = (ImageButton) this.findViewById(R.id.doneButton);
		final String receiver = this.getIntent().getStringExtra("receiver");
		if (this.getIntent().hasExtra("appIDs")) {
			appIDs = JSON.parses(this.getIntent().getStringExtra("appIDs"));
		} else {
			appIDs = new JSONArray();
		}
		allAppView.setData(appIDs);
		//
		doneButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Bundle bundle = new Bundle();
				bundle.putString("appIDs", JSON.stringify(allAppView.getData()));
				MESSAGE.send(message, receiver, bundle);
				finish();
			}

		});
	}

}
